package com.trex.modules.tbl.place.web;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.trex.modules.tbl.place.entity.TblZdZycs;
import com.trex.modules.tbl.place.service.TblZdZycsService;

/**
 * 作业场所Controller
 * @author jy
 * @version 2022-12-09
 */
@Controller
@RequestMapping(value = "/tbl/place/tblZdZycs")
public class TblZdZycsController extends BaseController {

	@Autowired
	private TblZdZycsService tblZdZycsService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public TblZdZycs get(String recId, boolean isNewRecord) {
		return tblZdZycsService.get(recId, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	//@RequiresPermissions("tbl:place:tblZdZycs:view")
	@RequestMapping(value = {"list", ""})
	public String list(TblZdZycs tblZdZycs, Model model) {
		model.addAttribute("tblZdZycs", tblZdZycs);
		return "modules/tbl/place/tblZdZycsList";
	}
	
	/**
	 * 查询列表数据
	 */
	//@RequiresPermissions("tbl:place:tblZdZycs:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<TblZdZycs> listData(TblZdZycs tblZdZycs, HttpServletRequest request, HttpServletResponse response) {
		tblZdZycs.setPage(new Page<>(request, response));
		Page<TblZdZycs> page = tblZdZycsService.findPage(tblZdZycs);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	//@RequiresPermissions("tbl:place:tblZdZycs:view")
	@RequestMapping(value = "form")
	public String form(TblZdZycs tblZdZycs, Model model) {
		model.addAttribute("tblZdZycs", tblZdZycs);
		return "modules/tbl/place/tblZdZycsForm";
	}

	/**
	 * 保存数据
	 */
	//@RequiresPermissions("tbl:place:tblZdZycs:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated TblZdZycs tblZdZycs) {
		tblZdZycsService.save(tblZdZycs);
		return renderResult(Global.TRUE, text("保存作业场所成功！"));
	}
	
	/**
	 * 删除数据
	 */
	//@RequiresPermissions("tbl:place:tblZdZycs:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(TblZdZycs tblZdZycs) {
		tblZdZycsService.delete(tblZdZycs);
		return renderResult(Global.TRUE, text("删除作业场所成功！"));
	}
	
}